package com.shenfa.action;

import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import com.shenfa.bean.PaperCityCrd;
import com.shenfa.service.EpibCityService;

import com.shenfa.util.ResultObject;

/**
 * 外包商作业分配ACTION
 * 
 * @author yanglong
 *
 */
@SuppressWarnings("serial")
public class EpibCityAction extends BaseAction {

	@Autowired
	private EpibCityService epibCityService;
	
	private PaperCityCrd paperCityCrd;
	private static Logger log=Logger.getLogger(EpibCityAction.class);
	private int start;
	private int limit;
	
	/**
	 * 根据对象条件查询外包商作业分配列表
	 */
	@SuppressWarnings("unchecked")
	public String list(){
		log.debug("start="+start+",limit="+limit+",cardNo="+paperCityCrd.getCard_no());
		List<PaperCityCrd> list = epibCityService.getList(paperCityCrd, start, limit);
		result = ResultObject.build("0", list);
		result.put("total", epibCityService.getCount(paperCityCrd));
		return SUCCESS;
	}
	
	/**
	 * 添加外包商作业分配信息
	 */
	public String add() {
		int type = epibCityService.add(paperCityCrd);
		if(type == 1){
			result = ResultObject.build(String.valueOf(type), "保存成功！");
		} else {
			result = ResultObject.build(String.valueOf(type), "操作失败！");
		}
		return SUCCESS;
	}

	/**
	 * 删除外包商作业分配信息
	 */
	public String del() {
		log.debug("cardNo"+paperCityCrd.getCard_no()+",businpntNo="+paperCityCrd.getBusinpnt_no());
		int type = epibCityService.del(paperCityCrd);
		if(type == 1){
			result = ResultObject.build(String.valueOf(type), "删除成功！");
		} else {
			result = ResultObject.build(String.valueOf(type), "操作失败！");
		}
		return SUCCESS;
	}

	/**
	 * 修改外包商作业分配信息
	 * @return
	 */
	public String upd() {
		log.debug("cardNo"+paperCityCrd.getCard_no()+",businpntNo="+paperCityCrd.getBusinpnt_no()+",cityNo="+paperCityCrd.getCity_no()+",printType="+paperCityCrd.getPrint_type());
		int type = epibCityService.upd(paperCityCrd);
		if(type == 1){
			result = ResultObject.build(String.valueOf(type), "保存成功！");
		} else {
			result = ResultObject.build(String.valueOf(type), "操作失败！");
		}
		return SUCCESS;
	}

	public PaperCityCrd getPaperCityCrd() {
		return paperCityCrd;
	}

	public void setPaperCityCrd(PaperCityCrd paperCityCrd) {
		this.paperCityCrd = paperCityCrd;
	}
	
	public void setStart(int start) {
		this.start = start;
	}

	public void setLimit(int limit) {
		this.limit = limit;
	}
}
